package cn.hyh.core.controller;

import cn.hyh.core.pojo.Experience;
import cn.hyh.core.pojo.User;
import cn.hyh.core.pojo.UserInfo;
import cn.hyh.core.service.ServiceInterface.UserService;
import cn.hyh.core.vo.ResultVo;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

/**
 * @auther :hyh
 * @desc :
 * @date :2019/7/11
 */

@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;







    /**
     *  获取用户的信息
     * @return
     */
    @RequestMapping("/getUserInfo")
    public Map<String,Object> userInfo() {
        UserInfo info= userService.getUserInfo();
        return ResultVo.successResult(info);
    }

    @RequestMapping(value = "/initExperience", method = RequestMethod.POST)
    public  Map<String,Object>   initExperience(){
        List<Experience> expList=userService.initExperience();
        return ResultVo.successResult(expList);
    }

    //获取游客的ip地址。
    @RequestMapping(value = "getVisitorAddress",method = RequestMethod.GET)
    public  Map<String,Object>  getVisitorAddress(HttpServletRequest request){
        int i =userService.getVisitorAddress(request);
        return ResultVo.successResult(i);
    }


}
